using Assets.Scripts.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UICharacterPool_Panel : MonoBehaviour
{
    #region 单例
    public static UICharacterPool_Panel Instance;
    void Awake()
    {
        Instance = this;
    }
    #endregion

    // 当前玩家选择的角色卡池中的牌
    public int currCharacterSelectedCardID = -1;

    private int currCardID;

    // 当前角色卡池中角色牌的配置
    public Dictionary<int, CharacterCard> currCharacterSelectedCardDic;


    #region 用于临时存放角色卡池中的角色item
    // 当前玩家选择的卡池的牌
    private int currPoolCardID = -1;
    // 用ID去确认某个卡池的item
    public UICharacterPool_Item[] uICharacterPool_Items;
    #endregion

    private void Start()
    {
        for (int i = 6; i < 12; i++)    // 初始化赋上值
        {
            currCharacterSelectedCardDic.Add(i-6, RoundManager.Instance.charCards[i]);
        }
    }
    /// <summary>
    /// 选中的角色卡池中的角色卡
    /// </summary>
    public void SelectCharacterCard(int cardID)
    {
        // 如果上一次选择和本次是一样的，就无视
        if (currPoolCardID == cardID)
        {
            return;
        }
        // 找到老的ID对应的实际UIItem元素，设置他的Select为False
        if (Instance.currCharacterSelectedCardDic.ContainsKey(currPoolCardID))
        {
            uICharacterPool_Items[currPoolCardID].IsSelect = false;
        }

        currPoolCardID = cardID;
        uICharacterPool_Items[currPoolCardID].IsSelect = true;

        // 让角色卡池面板脚本知道当前选择的角色卡
        Instance.currCharacterSelectedCardID = currCardID;
    }
}
